/*
 * @Author: He Songda hesongda@haier.com
 * @Date: 2024-01-11 09:42:03
 * @LastEditors: He Songda hesongda@haier.com
 * @LastEditTime: 2024-01-12 17:46:52
 * @FilePath: \my-code-service\router\list.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 引入路由
const Router = require("koa-router");
const list = new Router();
const bodyParser = require("koa-bodyparser");
const insertArticle = require("../service/listService/atticle.js");
list.use(bodyParser());

list.get("/apple", async (ctx) => {
  ctx.body = "苹果";
});
list.get("/banana", async (ctx) => {
  ctx.body = "香蕉";
});

list.post("/insertArticle", async (ctx) =>{
  // 处理插入文章的逻辑
  await insertArticle.insertArticle(ctx.request.body);
  console.log(ctx.request.body);
  ctx.body = {
    code: 200,
    data: null,
    msg: "scuess"
  };
})

// 导出
module.exports = list;
